import 'package:flutter/material.dart';

class routerDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        GestureDetector(
          onTap: () => _goNext(context, "Home"),
          child: Text("home"),
        ),
        GestureDetector(onTap: () => _goNext(context, "Me"), child: Text("me")),
      ],
    );
  }

  GestureTapCallback? _goNext(BuildContext context, String s) {

    Navigator.of(context).push(
      MaterialPageRoute(
        builder: (BuildContext context) {
          return PageDemo(titleStr: s);
        },
      ),
    );
  }
}

class PageDemo extends StatelessWidget {
  var titleStr;

  PageDemo({this.titleStr});

  @override
  Widget build(BuildContext context) {
    // ModalRoute.of(context).settings.arguments;
    return Scaffold(
      appBar: AppBar(title: Text(titleStr)),
      floatingActionButton: FloatingActionButton(
        onPressed: () => {
          debugPrint("点击 float 按钮"),
          // Navigator.pop(context)
          Navigator.pushNamed(context, "/b")

      },
        child: Icon(Icons.add),
      ),
    );
  }
}
